import configparser

# 创建ConfigParser对象
config = configparser.ConfigParser()

# 读取配置文件
config.read('config.ini')

# 将配置文件中的内容转换为字典
config_dict = {section: dict(config.items(section)) for section in config.sections()}

# 打印整个配置字典
print("Configuration as dictionary:")
print(config_dict)

# 访问特定部分和键
db_host = config.get('database', 'host')
db_port = config.getint('database', 'port')  # 使用getint获取整数
schema = config['DEFAULT']['schema']
table_name = config['table_conversion']['table_name']

print("\nAccessing specific values:")
print(f"Database host: {db_host}")
print(f"Database port: {db_port}")
print(f"Schema: {schema}")
print(f"Table name: {table_name}")